﻿<html>

<head>

<!--COMMON :include style and javascript code-->
${inc:/action/pub/common}
<SCRIPT SRC="${def:context}/js/getResponse.js" LANGUAGE="JavaScript" TYPE="text/javascript">
</SCRIPT>
<title>量房录入信息</title>

</head>

<body onmouseup="hidInputValidatorTip(3);" onkeypress="changekey(event)">
<!--a name="A0" id="A0"></a-->

<!--COMMON HEADER-->
${inc:/action/pub/header}

<center>

<!--filter form-->
<div id="divFilter" style="display:none;width:100%">
</div>

<!--addnew/edit form-->
<div id="divEditor" style="display:none;width:100%">
</div>

<!--insert/update response-->
<div id="divEditorResponse" style="display:none;width:100%">
</div>

<!--grid view response-->
<div id="response" style="display:none;width:100%">
</div>

<!--progress indicator-->
<div id="divStatus" class="alert" style="text-align:left; display:none;color:gray;width:150px;font-weight:bold;font-family:Arial">
    <img src="${def:context}/images/progress.gif"> 请稍候...
</div>

<!--show linked grid-->
<iframe id="detail" name="detail" marginwidth="0" scrolling="no" frameborder="0" style="height:0%;width:100%;visibility:hidden">
</iframe>

<!--用于传递当前目录到header模版中-->
<input type="hidden" name="actionroot" id="actionroot" value="${def:actionroot}">

</center>

</body>

</html>

<SCRIPT LANGUAGE="JavaScript">

//计算院内设施总额
function countYuanneiFee(){
	var array = new Array("dijiao2","shu2","guoshu2","shuijin_shouya2","chuqinshepeng2","shuijin_qita2",
						"zhaoqichi2","yuanqiang2","teshuguoshu_l12","teshuguoshu_l22",
						"teshuguoshu_l32","teshuguoshu_l42","teshuguoshu_l52","zhujuan2",
						"zilaishui2","cesuo2","shuinishe2","dianhua2","youxiandianshi2",
						"menlou_yi2","menlou_er2","fengbiyuanqiangmen2","banfengbiyuanqiangmen2");
	var totalFee = 0;
	for(var i=0;i<array.length;i++){
		var obj = document.forms["formEditor"].elements[array[i]];
		if(Trim(obj.value)==""){
			continue;
		}
		totalFee += parseFloat(Trim(obj.value));
	}
    //anthony 2010-5-12 小房除一等之外的所有费用合计 begin
    //alert("totalFee1:"+totalFee);
    var xiaofang_noyideng = getXiaofangFee();
    totalFee = totalFee +xiaofang_noyideng;
    //alert("totalFee2:"+totalFee);
    //anthony 2010-5-12 小房除一等之外的所有费用合计 end
	document.forms["formEditor"].elements["total_fee"].value = eval((Math.round(totalFee*100))/100);
}
//anthony 2010-5-12 小房除一等之外的所有费用合计 begin
function getXiaofangFee(){
    var totalFee = 0;
    //小房等级字段名前缀
    var xf_level = "xf_level";
    //小房价格字段前缀
    var xf_total = "xf_total";
    for(var i=1;i<=6;i++){
        //等级对象
        var levelObj = document.forms["formEditor"].elements[xf_level+i];
        //金额对象
        var totalObj = document.forms["formEditor"].elements[xf_total+i];
        if(Trim(levelObj.value)!= "一等"){
            if (parseFloat(Trim(totalObj.value)) >0)
            {
                totalFee += parseFloat(Trim(totalObj.value));
            }
        }
    }
    if (IsNumeric(totalFee))
    {
        return totalFee;
    }
    return 0;
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
};
//anthony 2010-5-12 小房除一等之外的所有费用合计 end
function onBlurHandler(price,ge,show){
	var p = document.forms["formEditor"].elements[price];
	var g = document.forms["formEditor"].elements[ge];
	var s = document.forms["formEditor"].elements[show];
	if(Trim(p.value)=="" || Trim(g.value)==""){
		return false;
	}
	var pVal = parseFloat(p.value);
	var gVal = parseFloat(g.value);
	if(gVal >= 0){
		var output = eval((Math.round(pVal*gVal*100))/100);
		s.value = output;
	}else{
		alert("请输入正确格式");
		g.focus();
		g.select();
		return false;
	}
	countYuanneiFee();
}

function MyCheckDouble(val)
{
	var obj = document.forms["formEditor"].elements[val];
    var input = obj.value;
	if(input == "") return true;
    var pos1 = input.indexOf(".");
    var pos2 = input.lastIndexOf(".");
    var charset = "1234567890.";
    if ((pos1 != pos2)||(!CheckChar(charset, input, true))) {
        alert ("请输入正确格式，只可包含数字和一个“.”！");
        obj.focus();
        obj.select();
        return false;
    }
	var output = eval((Math.round(input*100))/100);
	obj.value=output;
    
    return true;
}

//字段校验
function checkFields(){
	if(CheckNull("master_name","formEditor","请输入户主姓名！")) return false;
	if(CheckNull("project_name","formEditor","请选择项目名称！")) return false;
	if(CheckNull("cun_name","formEditor","请选择所在街道和村屯！")) return false;

//	if(!CheckRadio("user_sex","请选择性别","","formEditor")) return false;
//  if(!CheckRadio("is_local","请选择是否为坐地户","","formEditor")) return false;
//	if(!CheckRadio("single_status","请选择离婚丧偶情况","","formEditor")) return false;
//	if(!CheckRadio("is_onechild","请选择是否独生子女","","formEditor")) return false;
	if(!CheckRadio("is_touqin","请选择是否投亲","","formEditor")) return false;

    if(!MyCheckDouble("zf_number1"))return false;
	if(!MyCheckDouble("zf_area1"))return false;
	if(!MyCheckDouble("zf_price1"))return false;
	if(!MyCheckDouble("zf_number2"))return false;
	if(!MyCheckDouble("zf_area2"))return false;
	if(!MyCheckDouble("zf_price2"))return false;

	if(!MyCheckDouble("xf_area1"))return false;
	if(!MyCheckDouble("xf_price1"))return false;
	if(!MyCheckDouble("xf_total1"))return false;
	if(!MyCheckDouble("xf_area2"))return false;
	if(!MyCheckDouble("xf_price2"))return false;
	if(!MyCheckDouble("xf_total2"))return false;
	if(!MyCheckDouble("xf_area3"))return false;
	if(!MyCheckDouble("xf_price3"))return false;
	if(!MyCheckDouble("xf_total3"))return false;
	if(!MyCheckDouble("xf_area4"))return false;
	if(!MyCheckDouble("xf_price4"))return false;
	if(!MyCheckDouble("xf_total4"))return false;
	if(!MyCheckDouble("xf_area5"))return false;
	if(!MyCheckDouble("xf_price5"))return false;
	if(!MyCheckDouble("xf_total5"))return false;
	if(!MyCheckDouble("xf_area6"))return false;
	if(!MyCheckDouble("xf_price6"))return false;
	if(!MyCheckDouble("xf_total6"))return false;

	if(!MyCheckDouble("dijiao"))return false;
	if(!MyCheckDouble("dijiao2"))return false;
	if(!CheckNullNum("shu"))return false;
	if(!MyCheckDouble("shu2"))return false;
	if(!CheckNullNum("shuijin_shouya"))return false;
	if(!MyCheckDouble("shuijin_shouya2"))return false;
	if(!CheckNullNum("shuijin_qita"))return false;
	if(!MyCheckDouble("shuijin_qita2"))return false;
	if(!MyCheckDouble("chuqinshepeng"))return false;
	if(!MyCheckDouble("chuqinshepeng2"))return false;
	if(!MyCheckDouble("guoshu"))return false;
	if(!MyCheckDouble("guoshu2"))return false;

	if(!CheckNullNum("zhaoqichi"))return false;
	if(!MyCheckDouble("zhaoqichi2"))return false;
	if(!MyCheckDouble("yuanqiang"))return false;
	if(!MyCheckDouble("yuanqiang2"))return false;
	if(!CheckNullNum("teshuguoshu_l1"))return false;
	if(!MyCheckDouble("teshuguoshu_l12"))return false;
	if(!CheckNullNum("zhujuan"))return false;
	if(!MyCheckDouble("zhujuan2"))return false;
	if(!CheckNullNum("zilaishui"))return false;
	if(!MyCheckDouble("zilaishui2"))return false;
	if(!CheckNullNum("teshuguoshu_l2"))return false;
	if(!MyCheckDouble("teshuguoshu_l22"))return false;
	if(!CheckNullNum("teshuguoshu_l3"))return false;
	if(!MyCheckDouble("teshuguoshu_l32"))return false;
	if(!CheckNullNum("cesuo"))return false;
	if(!MyCheckDouble("cesuo2"))return false;
	if(!MyCheckDouble("shuinishe"))return false;
	if(!MyCheckDouble("shuinishe2"))return false;
	if(!CheckNullNum("teshuguoshu_l4"))return false;
	if(!MyCheckDouble("teshuguoshu_l42"))return false;
	if(!CheckNullNum("teshuguoshu_l5"))return false;
	if(!MyCheckDouble("teshuguoshu_l52"))return false;

	if(!CheckNullNum("dianhua"))return false;
	if(!MyCheckDouble("dianhua2"))return false;
	if(!CheckNullNum("youxiandianshi"))return false;
	if(!MyCheckDouble("youxiandianshi2"))return false;
	if(!CheckNullNum("menlou_yi"))return false;
	if(!MyCheckDouble("menlou_yi2"))return false;
	if(!CheckNullNum("menlou_er"))return false;
	if(!MyCheckDouble("menlou_er2"))return false;
	if(!CheckNullNum("fengbiyuanqiangmen"))return false;
	if(!MyCheckDouble("fengbiyuanqiangmen2"))return false;
	if(!CheckNullNum("banfengbiyuanqiangmen"))return false;
	if(!MyCheckDouble("banfengbiyuanqiangmen2"))return false;

	if(document.formEditor.liangfang_remak.value.length > 250){
		alert("备注信息长度不能超过250，请检查！");
		document.formEditor.liangfang_remak.focus();
		document.formEditor.liangfang_remak.select();
		return false;
	}

    return true;
}

function pickLevels(id,desc,flag){
	var url = "${def:context}/action/dq/pick/house-level/form";
	pickOpen (desc,id,url,'400','230',null,flag);
}

function searchBack(){
    document.getElementById("divFilter").style.display = "";
}

//新增时赋值
function policyValue(){
	//单价赋值（除了正房小房）
	document.formEditor.dijiao_policy.value = "${fld:dijiao_policy}";
	document.formEditor.shu_policy.value = "${fld:shu_policy}";
	document.formEditor.shuijin_shouya_policy.value = "${fld:shuijin_shouya_policy}";
	document.formEditor.shuijin_qita_policy.value = "${fld:shuijin_qita_policy}";
	document.formEditor.chuqinshepeng_policy.value = "${fld:chuqinshepeng_policy}";
	document.formEditor.guoshu_policy.value = "${fld:guoshu_policy}";
	document.formEditor.zhaoqichi_policy.value = "${fld:zhaoqichi_policy}";
	document.formEditor.yuanqiang_policy.value = "${fld:yuanqiang_policy}";
	document.formEditor.zhujuan_policy.value = "${fld:zhujuan_policy}";
	document.formEditor.zilaishui_policy.value = "${fld:zilaishui_policy}";
	document.formEditor.cesuo_policy.value = "${fld:cesuo_policy}";
	document.formEditor.shuinishe_policy.value = "${fld:shuinishe_policy}";
	document.formEditor.teshuguoshu_l1_policy.value = "${fld:teshuguoshu_l1_policy}";
	document.formEditor.teshuguoshu_l2_policy.value = "${fld:teshuguoshu_l2_policy}";
	document.formEditor.teshuguoshu_l3_policy.value = "${fld:teshuguoshu_l3_policy}";
	document.formEditor.teshuguoshu_l4_policy.value = "${fld:teshuguoshu_l4_policy}";
	document.formEditor.teshuguoshu_l5_policy.value = "${fld:teshuguoshu_l5_policy}";
	document.formEditor.dianhua_policy.value = "${fld:dianhua_policy}";
	document.formEditor.youxiandianshi_policy.value = "${fld:youxiandianshi_policy}";
	document.formEditor.menlou_yi_policy.value = "${fld:menlou_yi_policy}";
	document.formEditor.menlou_er_policy.value = "${fld:menlou_er_policy}";
	document.formEditor.fengbiyuanqiangmen_policy.value = "${fld:fengbiyuanqiangmen_policy}";
	document.formEditor.banfengbiyuanqiangmen_policy.value = "${fld:banfengbiyuanqiangmen_policy}";
}

function addNewBackSetting(){
	//单价赋值（除了正房小房）
    policyValue();
	document.forms["formEditor"].elements["master_name"].focus();
}


function validateMasterName(val){
	if(val == "")return false;
	var tuid = document.forms["formEditor"].elements["tuid"].value;
    var newFlag = (tuid==""?true:(tuid=="0"?true:false));
	if(newFlag == false)return false;
	return ajaxCall(httpMethod="GET", 
                        uri=$("actionroot").value+"/findMaster" + "?master_name=" + encodeURIComponent(val), 
                        divResponse="divEditorResponse",
                        divProgress="divStatus", 
                        formName=null, 
                        afterResponseFn=null, 
                        onErrorFn=showGrid);	
}

loadEditor();
loadFilter(search);

//1户籍信息维护
function mastDetail(id){
    var url = "${def:context}/action/dq/master_detail/crud?id=" +id+"&random="+Math.random();
    document.location.href = url; 
}

//3费用发放 anthony 
function masterFee(id){
    var url = "${def:context}/action/dq/fee/crud?id=" +id+"&random="+Math.random();
    document.location.href = url; 
}
//4回迁室型 anthony 
function placement(id){
    var url = "${def:context}/action/dq/yewu/anzhilouyuan/placement/crud?id=" +id+"&random="+Math.random();
    document.location.href = url; 
}
//管理 
function manage(id){
	var url = "${def:context}${def:actionroot}/tabs?id="+id;
	if("${fld:flag}" == "shenhe"){
		url += "&flag=shenhe";
	}
	url += "&random="+Math.random();
	var titleString = "manage"+id;
	var ScWidth = screen.availwidth - 10;
	var ScHeight = screen.availheight - 48;
	var WindowOption = "location=no,menubar=yes,toolbar=no,scrollbars=yes,status=yes,resizable=yes,top=0,left=0";
	WindowOption = WindowOption + ",width=" + ScWidth;
	WindowOption = WindowOption + ",height=" + ScHeight;
	var newWin = window.open(url, titleString, WindowOption);
	newWin.focus();
}

function printHandler(id){
	var url = "${def:context}${def:actionroot}/print?id="+id+"&random="+Math.random();
	var titleString = "buchang";
	var ScWidth = screen.availwidth - 10;
	var ScHeight = screen.availheight - 48;
	var WindowOption = "location=no,menubar=yes,toolbar=no,scrollbars=yes,status=yes,resizable=yes,top=0,left=0";
	WindowOption = WindowOption + ",width=" + ScWidth;
	WindowOption = WindowOption + ",height=" + ScHeight;
	var newWin = window.open(url, titleString, WindowOption);
	newWin.focus();
}

function changekey0(){
	switch (event.keyCode)
	{
		case 13:
		case 39:
		case 40:
			event.keyCode = 9;
			return;
		//case 37:
		//case 38:
			//event.shiftKey;
			//event.keyCode = 9;
		//return;
	}
}

function changekey(evt){
	evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
  var keycode = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值	
	
	if(keycode != 37 && keycode != 38 && keycode != 39 && keycode != 40)   
		return   true; 

	var actEle=document.activeElement;	
  if(!actEle) {document.getElementsByTagName("input")[0].focus();   return;}  
  var allEles = document.getElementsByTagName("*");
	
  var actIndex=actEle.sourceIndex; 
	if(!actIndex){
	  for(var i=0;i<allEles.length;i++){//兼容FF
	  	if(allEles[i].name==actEle.name)
	  	actIndex = i;
	  }
	}
  

	if(keycode == 37 || keycode == 38){
	  for(var i = actIndex-1;i>=0;i--){

	  	if(Test(allEles[i].tagName) && allEles[i].readOnly == false && allEles[i].type !="hidden"){  
	  		//window.event.returnValue=false;
	  		allEles[i].focus();
	  		return   false;
	  	}
	  }
	}

	if(keycode == 39 || keycode == 40){
	  for(var i=actIndex+1;i<allEles.length;i++){
	  	if(Test(allEles[i].tagName) && allEles[i].readOnly == false && allEles[i].type !="hidden"){

				//window.event.returnValue=false;
	  		allEles[i].focus();
	  		return   false;
	  	}
	  }
	}

  return   false;   
}

  function   Test(tag){  
  var   regTag="INPUT|SELECT|TEXTAREA|BUTTON|RADIO";//可以在这里添加需要获得焦点的对象的tagname  
  var   tags = regTag.split("|");  
  for(var i=0;i<tags.length;i++){
  	if(tag==tags[i])  
  		return   true;  
  }
  return   false;  
  }   
  
  function changeMyFocusByKey(left,up,right,down){
	var evt = getEvent();
	var keycode = evt.keyCode?evt.keyCode:evt.which;
	switch (keycode)
	{
		case 37:
			if(left == "") return;
			document.forms["formEditor"].elements[left].focus();
			document.forms["formEditor"].elements[left].select();
			break;
		case 38:
			if(up == "") return;
			document.forms["formEditor"].elements[up].focus();
			document.forms["formEditor"].elements[up].select();
			break;
		case 39:
			if(right == "") return;
			document.forms["formEditor"].elements[right].focus();
			document.forms["formEditor"].elements[right].select();
			break;
		case 40:
			if(down == "") return;
			document.forms["formEditor"].elements[down].focus();
			document.forms["formEditor"].elements[down].select();
			break;
	}
  }

  function getEvent() //同时兼容ie和ff的写法 
    {  
        if(document.all)  return window.event;    
        func=getEvent.caller;        
        while(func!=null){  
            var arg0=func.arguments[0]; 
            if(arg0) 
            { 
              if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
              {  
              return arg0; 
              } 
            } 
            func=func.caller; 
        } 
        return null; 
    } 
    //anthony
    function getDeleteFunction(table_name,tuid,buttonstatus){
        if(buttonstatus == "disabled"){
            if(window.confirm("已经审核的数据一旦删除会把相关数据全部删除，确定删除？")){
				deleteSysData(table_name,tuid);
			}
        }else{
            deleteSysData(table_name,tuid);
        }
    
    }
    //清空filterForm进行查询 anthony 2010-12-02
    function clearAndSearch(){
        clearForm("formFilter");
        search();
    }

</script>
    